package com.rookie.behavioral.observer;

/**
 * @author rookie
 * @date 2022/5/7 14:28
 */
public class CriminalObservable extends Observable{

    public void crime(String event) {
        System.out.println("罪犯正在" + event);
        notifyObservers(event);
    }

    public static void main(String[] args) {
        CriminalObservable zhangSan = new CriminalObservable();
        PoliceObserver police1 = new PoliceObserver();
        PoliceObserver police2 = new PoliceObserver();
        PoliceObserver police3 = new PoliceObserver();
        zhangSan.addObserver(police1);
        zhangSan.addObserver(police2);
        zhangSan.addObserver(police3);
        zhangSan.crime("放狗咬人");
    }
}
